"""author: wenyao
   data: 2021/5/20
   project: devopscmdb
"""
import time
import functools
def cost(func):
    print("i am cost")
    #把func的元数据复制给_cost
    #保留元数据
    @functools.wraps(func)
    def _cost(*args, **kwargs):
        start = time.time()
        result = func(*args,**kwargs)
        end = time.time()
        print(f"{func.__name__}执行花了{end-start}s")
        return result
    return _cost

@cost  #--> cost(add)
def add(a,b):
    """
    :param a:
    :param b:
    :return:

    this is add func
    """
    return a+b
print(add.__name__)
print(add.__doc__)